-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
275 add co2 sensor support to smibhid #276
Conversation
Added BME280 module for easier testing. |
Just tried some tests without any modules installed as I don't have any yet.
|
Not great at tinyweb/flask so have yet to really look at that, is a valid finding. But we could choose to add to a new issue to improve rather than adding complexity to this one given how big it has already grown. Any ideas how to modify the website.py file to achieve this? |
Personally I would suggest a layout more like this, grouping things better? You may disagree
|
R.e. the 404 thing looks like if you do the following a 404 error is returned correctly. I tested it with a broad try/except but the KeyError looks to be the exception that gets triggered. from http.webserver import HTTPException
...
...
...
class Modules():
def get(self, data, sensors, logger: uLogger) -> str:
logger.info("API request - sensors/modules")
try:
html = dumps(sensors.get_modules())
logger.info(f"Return value: {html}")
except KeyError:
raise HTTPException(404)
return html |
Have you had a chance to look at the 404 thing from the above comment? Do we want as a different issue? |
Just tried the BME280 module, am investigating
|
I got the same error at the space but not on my test setup. I wrapped that
calculation in int() as a fix but not pushed yet.
…On Fri, 14 Mar 2025, 22:12 sam57719, ***@***.***> wrote:
Just tried the BME280 module, am investigating
Task exception wasn't retrieved
future: <Task> coro= <generator object '_poll_sensors' at 20024260>
Traceback (most recent call last):
File "asyncio/core.py", line 1, in run_until_complete
File "lib/sensors/__init__.py", line 70, in _poll_sensors
File "lib/sensors/__init__.py", line 98, in get_readings
File "lib/sensors/BME280.py", line 263, in get_reading
File "lib/sensors/BME280.py", line 176, in read_compensated_data
File "lib/sensors/BME280.py", line 161, in read_raw_data
TypeError: can't convert float to int
—
Reply to this email directly, view it on GitHub
<#276 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB7IXA4NO2KRYH5VSJSS5SL2UNH5NAVCNFSM6AAAAABYSJ6K32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRVHA4DMNJRGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
[image: sam57719]*sam57719* left a comment (somakeit/smib#276)
<#276 (comment)>
Just tried the BME280 module, am investigating
Task exception wasn't retrieved
future: <Task> coro= <generator object '_poll_sensors' at 20024260>
Traceback (most recent call last):
File "asyncio/core.py", line 1, in run_until_complete
File "lib/sensors/__init__.py", line 70, in _poll_sensors
File "lib/sensors/__init__.py", line 98, in get_readings
File "lib/sensors/BME280.py", line 263, in get_reading
File "lib/sensors/BME280.py", line 176, in read_compensated_data
File "lib/sensors/BME280.py", line 161, in read_raw_data
TypeError: can't convert float to int
—
Reply to this email directly, view it on GitHub
<#276 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB7IXA4NO2KRYH5VSJSS5SL2UNH5NAVCNFSM6AAAAABYSJ6K32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRVHA4DMNJRGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
BME280 looks good with that {
"BME280": {
"pressure": 110000,
"humidity": 41.1409,
"temp": 17.31532
}
} |
In my haste to get it working, I missed that the library had a property that formatted the raw values correctly, I have called that in get_reading() instead and it all works much better. Pushed that to branch. I might make a similar version that adds the units in the dict for better consumption by a script calling the API. But will do that when needed. |
…units and adjust sensor list to list of dicts including bame and unit.
Adjusted all 3 drivers to provide sensible precision for values and remove all units. Adjusted list of sensors to be a list of dicts with name and unit. |
This is logical, however tinyweb only seems to support the variable being the URL suffix and not mid URL. Will see if this can be fixed easily. |
I'm going to restructure as suggested but not provide the module specific reading list for now. It looks like tinyweb has a PR that would solve this, but is not something I will put in this PR as a little complex. belyalov/tinyweb#51 |
Looks good, apart from the [
{
"name": "pressure",
"unit": "hPa"
},
{
"name": "temperature",
"unit": "°C"
},
{
"name": "humidity",
"unit": "%"
} |
Degrees sign was messing with JSON dumps() removed and added comment not to readd. I suspect going down a fix dumps upstream for special characters rabbit hole is not a good use of time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All issues I found have been sorted!
Add capability to add sensor modules on I2C that will poll on async loop and present their module information and readings on the API.
Fixed I2C not being defined at HID and main level to prevent incorrectly specifying different I2C parameters across the code.
Fixed updater crashing if the updates folder is not present.